import Vue from "vue";

import VueRouter from "vue-router";
const Home = () => import('@/pages/Home')
const Search = () => import("@/pages/Search")
const Login = () => import("@/pages/Login")
const Register = () => import("@/pages/Register")
const Detail = () => import("@/pages/Detail")

Vue.use(VueRouter);

//重写push

const lastRouter = VueRouter.prototype.push

VueRouter.prototype.push = function myPush(location, onComplete = () => { }, onAbort = () => { }) {
  return lastRouter.call(this, location, onComplete, onAbort)
}

export default new VueRouter({
  mode: 'history',
  routes: [
    { path: '/home', component: Home, name: 'home' },
    { path: '/login', component: Login, name: 'login', meta: { footerIsShow: true } },
    {
      path: '/search/:keyword?',
      component: Search,
      name: 'search',
    },
    {
      path: '/detail/:skuId',
      component: Detail,
      name: 'detail',
    },
    { path: '/register', component: Register, name: 'register' , meta: { footerIsShow: true }},
    { path: '/', redirect: '/home' }
  ]
})